package com.enzo.prms.common.taglib.pagination;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

/**
 * @author prms1.0
 * 
 * @date:2012-6-14 ����03:05:33
 * @version :
 * 
 */
public class DisplayTag extends TagSupport {
	private static final long serialVersionUID = -3898803410355044221L;
	private String name;

	@Override
	public int doEndTag() throws JspException {
		JspWriter out = pageContext.getOut();
		boolean bShowAll=CollectionTag.getRequestAttributeAsBoolean(pageContext, "pageInfo.showAll", false);
		try {
			if (name.indexOf("showAll") >= 0) {
				generateShowAll(out, bShowAll);
			}
		} catch (IOException e) {
			e.printStackTrace();
		} catch (Exception e) {
			throw new JspException(e);
		}
		return 6;
	}

	private void generateShowAll(JspWriter out, boolean bShowAll)
			throws IOException {
		StringBuffer sb = new StringBuffer();
		sb.append("<input type=\"checkbox\" ");
		if (bShowAll) {
			sb.append("checked=\"true\" ");
		}
		sb.append("name=\"pageInfo.showAll\" ");
		sb.append("onclick=\"javascript:doShowAll").append(
				"();\"");
		sb.append(" />");
		out.print(sb.toString());
		
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	

}
